package com.lagou.demo.controller;

import java.io.IOException;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Security({"zhangsan", "lisi", "wangwu"})
@LagouController
@LagouRequestMapping("/demo")
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param username
     * @return
     */
    @LagouRequestMapping("/query")
    public void query(HttpServletRequest request, HttpServletResponse response,String username) throws IOException {
        response.getWriter().write("hello," + username);
    }

    @Security("lisi")
    @LagouRequestMapping("/query2")
    public void query2(HttpServletRequest request, HttpServletResponse response,String username) throws IOException {
        response.getWriter().write("hello," + username);    }

    @Security("wangwu")
    @LagouRequestMapping("/query3")
    public void query3(HttpServletRequest request, HttpServletResponse response,String username) throws IOException {
        response.getWriter().write("hello," + username);    }
}
